/**
 * SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
 * SPDX-License-Identifier: Mulan PSL v2
 */
/**
 * @file created by zzz 2019/10/26.
 * ip或ip:port
 */

import Validator from '../validation/validator';
import SfVueComponent from '@sxf/sf-vue-component';

let ipv4Validator = SfVueComponent.vtypes.get('ipv4').validator;
let portValidator = SfVueComponent.vtypes.get('port').validator;

export default class IPRange extends Validator {
    verify (v) {
        let [ip, port] = v.split(':');
            let ret = true;

        ret = ipv4Validator.verify(ip);
        if (ret !== true) {
            return ret;
        }

        if (port) {
            ret = portValidator.verify(port);
        }

        return ret;
    }
};
